#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#define LL long long
#define nextLine() {int c = 0; while ((c = getchar()) != EOF && c != 10);}
#define sqr(a) ((a) * (a))
#define fill(a, c) memset(a, c, sizeof a)
#define ldb long double
#define sgn(a) ((a) > eps ? 1 : -1)
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));
const int INF = 1 << 28;
const LL LINF = 1ll << 50;
const ldb LDINF = 1e70;
const ldb cos3 = cos(pi / 3);
const ldb sin3 = sin(pi / 3);
using namespace std;


int n, m;
LL d1[1010][1010];
LL d[1010][1010];
int a[1001][1001];
int up[1001];
int dn[1001][1001];
int ct[1001][1001];
int cnt;
vector <pair<int, int> > all;

void Load()
{
	cin >> n >> m;
	              nextLine();
	int i, j;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			c = getchar();
			if (c == 'X')
			{
				a[i][j] = 1;
				cnt++;
			}
			else a[i][j] = 0;
		}
		nextLine();
	}
}


vector <int> st;


void Solve()
{
	int i, j;
	for (i = 0; i < m; i++)
	{
		d1[0][i] = i * (i + 1) / 2;
	}
	for (i = 0; i < n; i++)
	{
		d1[i][0] = i * (i + 1) / 2;
	}
	for (i = 1; i < n; i++)
	{
		for (j = 1; j < m; j++)
		{
			d1[i][j] = d1[i - 1][j - 1] + (LL)2 * i * j + i * (i + 1) / 2 + j * (j + 1) / 2;
			d[i][j] += d1[i - 1][j - 1];
		}
	}
	for (i = 0; i < m; i++)
	{
		d1[0][i] = (m - i - 1) * (m - i) / 2; 
	}
	for (i = 0; i < n; i++)
	{
		d1[i][m - 1] = i * (i + 1) / 2; 
	}
	for (i = 1; i < n; i++)
	{
		for (j = 1; j < m - 1; j++)
		{
			d1[i][j] = d1[i - 1][j + 1] + (LL)2 * i * (m - 1 - j) + i * (i + 1) / 2 + (m - j - 1) * (m - j) / 2;
			d[i][j] += d1[i - 1][j + 1];
		}
	}
	for (i = 0; i < m; i++)
	{
		d1[n - 1][i] = (m - i - 1) * (m - i) / 2; 
	}
	for (i = 0; i < n; i++)
	{
		d1[i][m - 1] = (n - i - 1) * (n - i) / 2; 
	}
	for (i = n - 2; i >= 0; i--)
	{
		for (j = 0; j < m - 1; j++)
		{
			d1[i][j] = d1[i + 1][j + 1] + (LL)2 * (n - i - 1) * (m - 1 - j) + (n - i - 1) * (n - i) / 2 + (m - j - 1) * (m - j) / 2;
			d[i][j] += d1[i + 1][j + 1];
		}
	}
	for (i = 0; i < m; i++)
	{
		d1[n - 1][i] = (i) * (i + 1) / 2; 
	}
	for (i = 0; i < n; i++)
	{
		d1[i][0] = (m - i - 1) * (m - i) / 2; 
	}
	for (i = n - 2; i >= 0; i--)
	{
		for (j = 1; j <= m - 1; j++)
		{
			d1[i][j] = d1[i + 1][j - 1] + (LL)2 * (n - i - 1) * j + (n - i - 1) * (n - i) / 2 + j * (j + 1) / 2;
			d[i][j] += d1[i + 1][j - 1];
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			d[i][j] += (LL)i * (i + 1) / 2 + (LL)j * (j + 1) / 2 + (LL)(n - i - 1) * (n - i) / 2 + (LL)(m - j - 1) * (m - j) / 2;
		}
	}
	for (i = 0; i < m; i++)
	{
		if (a[n - 1][j] == 1) ct[n - 1][j] = 1, dn[n - 1][j] = i;
		else dn[n - 1][j] = n;
	}
	for (i = n - 2; i >= 0; i--)
	{
		for (j = 0; j < m; j++)
		{
			ct[i][j] += ct[i + 1][j];
			if (a[i][j]) ct[i][j]++, dn[i][j] = i;
			else dn[i][j] = dn[i + 1][j];
		}
	}
	
	for (i = 0; i < m; i++) up[i] = -1;
	int lt;
	int lt_bad;
	for (i = 0; i < n; i++)
	{
		for (j = m - 1; j >= 0; j--)
			if (a[i][j] == 1) st.push_back(j);
		lt_bad = 0;
		for (j = 0; j < m; j++)
		{
			if (a[i][j]) 
			{
				lt = a[i][j];
				lt_bad++;
				st.pop_back();
				up[j] = i;
				continue;
			}
			res += (d[i][j] + 1 - cnt) / 

		}
	}

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in", "rt", stdin);
	freopen("out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}